#ifndef _WMI_SHARE_H
#define _WMI_SHARE_H

/******************************************************************************
** @file	wmi_share.h
** @author	Juan Windzor Urena
** @author  Andrea Herbas
**
** @date	Jul 22, 2010
**
** @desc	This class represents a win32_WShare class and all its data 
**          members.
**			
**
******************************************************************************/

#include <string>
#include <iostream>
#include <comdef.h>
#include <Wbemidl.h>
#include "wmi_utils.h"
#include "wmi_constants.h"
#include "wmi_iwinobject.h"
#include <log4cxx\logger.h>
#include <log4cxx\xml\domconfigurator.h>

#pragma comment(lib, "wbemuuid.lib")

class WMI_Share : public WMI_IWinObject 
{
private:
    /**
    * Initializes each of the class' attributes, only
    * if they have a valid value.
    *
    * @param var data to be stored in a class' attribute.
    * @param i an int that represents the type of a resource.
    */
    void setData(VARIANT& var, int i);

public:
	/**
	* Class constructor 
    *
	* @param WMI_IWinObject 
	*/
    WMI_Share(IWbemClassObject*);

    /**
    * Class destructor
    */
    ~WMI_Share();

    /**
    * Sets the accessMask, in some Windows versions is not longer used.
    *
    * @param accMask Bit array that represents the access rights that are 
    * required to access or perform specific operations on the file or directory.
    */
    void 
    WMI_Share::setAccessMask(long accMask)
    {
        _accessMask = accMask;
    }

    /**
    * Retrieves the value of the accessMask attribute
    *
	* @return the accessMask value that represents the access rights
	*/
	long 
    WMI_Share::getAccessMask()
    {
	    return _accessMask;
    }

    /**
    * Sets the availability of the WShared resource.
    *
    * @param allowMAx true if the resource is not limited, otherwise false.
    */
    void 
    WMI_Share::setAllowMaximum(bool allowMax)
    {
        _allowMaximum = allowMax;
    }

    /**
    * Retrieves the value of the AllowMaximum attribute.
    *
	* @return true if the number of concurrent users o this resource is not limited,
    * otherwise returns false.
	*/
	bool 
    WMI_Share::getAllowMaximum()
    {
	    return _allowMaximum;
    }

    /**
    * Sets a short description os the resource.
    *
    * @param caption s a one line description of the resource.
    */
    void 
    WMI_Share::setCaption(wstring& caption)
    {
        _caption = caption;
    }

    /**
    * Retrieves the value of the caption attribute.
    *
	* @return caption that is a one line description of the resource.
	*/
	wstring& 
    WMI_Share::getCaption()
    {
	    return _caption;
    }

    /**
    * Sets a short description of the resource.
    *
    * @param description of the object
    */
    void 
    WMI_Share::setDescription(wstring& description)
    {
        _description = description;
    }
	
    /**
    * Retrieves the description value.
    *
	* @return description of the resource.
	*/
	wstring& 
    WMI_Share::getDescription()
    {
	    return _description;
    }

    /**
    * Sets the maximum limit of concurrent access to this resource.
    *
    * @param maxAllowed limit maximum of users allowed to use this resource
    * concurrently.
    */
    void 
    WMI_Share::setMaximumAllowed(long maxAllowed)
    {
        _maximumAllowed = maxAllowed;
    }

    /**
    * Retrieves the max quantity of users that can access the resource.
    *
	* @return the maximumAllowed that represents the maximum quantity
    * of users to access the WMI_Share concurrently.
	*/
	long 
    WMI_Share::getMaximumAllowed()
    {
	    return _maximumAllowed;
    }

    /**
    * Sets the date, that was pre-processed by an util method in
    * WMI_Utils.h
    *
    * @param installDate a date time 
    */
    void 
    WMI_Share::setInstallDate(CTime& dateTime)
    {
        _installDate = dateTime;
    }

    /**
    * Retrieves a formatted value of date
	* @return the installDate a Ctime object that encapsulates
    * the date and time.
	*/
    CTime& 
    WMI_Share::getInstallDate()
    {
	    return _installDate;
    }

    /**
    * Stes an alias of a WShared file.
    *
    * @name alias given to a WMI_Share on a computer.
    */
    void 
    WMI_Share::setName(wstring& name)
    {
        _name = name;
    }

    /**
    * Retrieves the name of the resource.
	* @return the Name that represents the alias of the WMI_Share
	*/	
    wstring& 
    WMI_Share::getName()
    {
	    return _name;
    }

    /**
    * Sets the location of the WMI_Share.
    *
    * @param path local path to the windows WMI_Share.
    */
    void 
    WMI_Share::setPath(wstring& path)
    {
        _path = path;
    }

    /**
    * Retrieves the resource path as an string.
    *
	* @return the path to the current WMI_Share.
	*/
	wstring& 
    WMI_Share::getPath()
    {
	    return _path;
    }

    /**
    * Sets the current status of the WMI_Share.
    *
    * @param status of the WShared resource.
    */
	void 
    WMI_Share::setStatus(wstring& status)
    {   
        _status = status;
    }

    /**
    * Retrieves the value of the current status.
    *
	* @return the status of the current WMI_Share.
	*/
	wstring& 
    WMI_Share::getStatus()
    {
	    return _status;
    }

    /**
    * Sets the resource type by passing an int, this int
    * has to be preccessed to return a type as a wstring.
    *
    * @param type int that represents an defined type.
    */
    void 
    WMI_Share::setType(int type)
    {
        switch(type)
        {
        case 0:
            _type = DISK_DRIVE;
            break;
        case 1:
            _type = PRINT_QUEUE;
            break;
        case 2:
            _type = DEVICE;
            break;
        case 3:
            _type = IPC;
            break;
        case -2147483648:
            _type = DISK_DRIVE_ADMIN;
            break;
        case -2147483649:
            _type = PRINT_QUEUE_ADMIN;
            break;
        case -2147483650:
            _type = DEVICE_ADMIN;
            break;
        case -2147483645:
            _type = IPC_ADMIN;
            break;
        }
    }

    /**
    * Retrieve the resource type.
    * @return the resource type.
    */
    wstring& 
    WMI_Share::getType()
    {
	    return _type;
    }

    /**
    * Put the object in a valid string, generally to be displayed.
    */
    void print();

private:
	/**
	* Bit array that represents the access rights that are required 
	* to access or perform specific operations on the file or directory.
	*/
	long _accessMask;

	/**
	* Number of concurrent users for this resource has been limited.
	* If true, the value in the MaximumAllowed property is ignored.
	*/
	bool _allowMaximum;

	/**
	* Short description (one-line string) of the object.
	*/
	wstring _caption;

	/**
	* Description of the object.
	*/
	wstring _description;

	/**
    * Object was installed. This property does not 
	* need a value to indicate that the object is installed.
	*/
	CTime _installDate;

	/**
	* Limit on the maximum number of users allowed to 
	* use this resource concurrently.
	*/
	long _maximumAllowed;

	/**
	* Alias given to a path set up as a WMI_Share on a computer system running Windows.
	*/
	wstring _name;

	/**
	* Local path of the Windows WMI_Share.
	*/
    wstring _path;

	/**
	* Current status of the object."OK", "Error", "Degraded", "Unknown", "Pred Fail",
	* "Starting", "Stopping", "Service", "Stressed", "Nonrecover", "NoContact", "LostComm"
	*/
	wstring _status;

    /**
    * Type of the resource being shared. Ex: Disk Drive or Device.
    */
    wstring _type;
    
    /**
    * Each of the class data members in a constant array.
    */
	static const wstring properties[];
};

#endif  //_SERVICE_H